<?php

// Header 
$this->set('title_for_layout', __("Thống kê truy cập", true));

$this->left_menu = 'menu/'.$this->params['controller'];

// Load Css

// Load Javascript
echo $this->Html->script('/access_logs/js/index');

?>
<script language="javascript" type="text/javascript">
var page = <?php echo $paginator->params['paging']['AccessLog']['page'];?>;
var max = <?php echo $paginator->params['paging']['AccessLog']['defaults']['limit'];?>;

$(document).ready(function() {
	$('div.buttons a.delete').click(function() {
		if (confirm("<?php __("Bạn có thật sự muốn xóa những thông tin truy cập này?")?>")) {
			var checkboxes = $('input[type="checkbox"].index');
			$('form#mass_delete').append(checkboxes).submit();
		}
	});
});
</script>

<h2 class='page_heading'><?php __("Các truy cập")?> / <?php echo (!empty($category) ? $category : __("Tất cả", true))?></h2>
<?php echo $session->flash()?>
<div class="buttons atbottom">
	<ul>
		<li><a href="javascript:void(0)" class="cancel delete"><?php __("Xóa")?></a></li>
	</ul>
</div>
<!-- buttons.end -->

<!-- table -->
<div class="table">
	<table cellpadding="0" cellspacing="0" id='news_list'>
		<thead>
			<tr>
				<th width='20'><a><?php echo __("#"); ?></a></th>
				<th width='20'><input type="checkbox" id='checkbox-control' control='index'/></th>
				<th width='170'><?php echo $paginator->sort(__("Thành viên", true), "User.username"); ?></th>
				<th><?php echo $paginator->sort(__("Thông tin", true), 'AccessLog.log_message'); ?></th>
				<th width='120'><?php echo $paginator->sort(__("Ngày", true), 'AccessLog.created'); ?></th>
			</tr>
		</thead>
		<tbody>
			<?php if(!$records):?>
			<tr class="row1">
				<td colspan="8" align="center" style="font-weight:bold"><?php echo __("Chưa có thông tin nào được lưu lại.");?></td>
			</tr>
			<?php
			endif;
				$max = $paginator->params['paging']['AccessLog']['defaults']['limit'];
				$page = $paginator->params['paging']['AccessLog']['page'];
				$start = ($page - 1) * $max;
				$i=0;
				$class = 'altrow';
				$room_type_list = array();
				foreach ($records as $item):
					$class = $class == "" ? "class='odd'" : "";
					$page_id = $item['AccessLog']['id'];
					//$class = "row".($i%2)?"0":"1";
					$i++;
			?>
			<tr <?php echo $class?> page_id="<?php echo $page_id?>">
				<td class="center"><?php echo ($start + $i)?></td>
				<td class="center"><input type="checkbox" class='index' name='checkbox_index[]' value='<?php echo $page_id?>'/></td>
				<td><?php echo $item['User']['username']?></td>
				<td><?php echo $item['AccessLog']['log_message']?></td>
				<td align='center'><?php echo date("Y-m-d H:i:s", strtotime($item['AccessLog']['created']))?></td>
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
</div>
<!-- table.end -->

<!-- paging -->
<div class="paging-wrapper">
<?php echo $this->element('pagination/pagination', array('model' => 'AccessLog'));?>
</div>
<!-- paging.end -->

<!-- buttons -->
<div class="buttons atbottom">
	<ul>
		<li><a href="javascript:void(0)" class="cancel delete"><?php __("Xóa")?></a></li>
	</ul>
</div>
<!-- buttons.end -->

<!-- Form cho sự kiện xóa -->
<form style="display:none" id='mass_delete' method='post' 
action="<?php echo $html->url(array('plugin' => 'access_logs', 'controller' => 'access_logs', 'action' => 'mass_delete'))?>"
></form>

<?php //echo $this->element('sql_dump')?>